package com.example.tests;
import org.junit.*;
import static org.junit.Assert.*;

import com.example.pages.UserPage;
//import org.openqa.selenium.*;

public class createNewUserTest extends TestBase {
     
        @Test
        public void CreateNewUser() {
                UserPage userPage = goToMainPage()
                .logInCorrectUser("admin", "admin")
                .goToUserManagementPage();
                
             
                SortedListOf<User> oldUserList = userPage.getUsers();
                
                User user = new User()
               .withName("varvashtyan").withEmail("v@gmail.com").withPassword("test");
                if (oldUserList.contains(user)) {
                	userPage.deleteNewUser(user);
                	oldUserList = userPage.getUsers();
                }
                userPage.createNewUser(user);
                
            // compare old list & new list
               SortedListOf<User> newUserList = userPage.getUsers();
               assertEquals(newUserList.size(), oldUserList.size() + 1);
               assertEquals(newUserList, oldUserList.withAdded(user));
              // userPage.deleteNewUser(user);
             }

 }


